﻿using System;
using System.Web.Mvc;
using YouWei.Utility;
using YouWei.Utility.Logging;

namespace YouWei.Op.Common
{
    public class CustomHandleErrorAttribute:HandleErrorAttribute
    {
        public override void OnException(ExceptionContext filterContext)
        {
            //记录安全日志
            try
            {
                Log4netLog.Error(new ErrorLog()
                {
                    ClientIP = IPHelper.IPAddress,
                    CreatedDate = DateTime.Now,
                    ErrorMessage = filterContext.Exception.Message,
                    ErrorSource = filterContext.Exception.Source,
                    ErrorTrace = filterContext.Exception.StackTrace,
                    RequestUrl = filterContext.HttpContext.Request.Url.PathAndQuery,
                    Platform = 100

                });
            }
            catch (Exception ex)
            {
                Log4netLog.Debug(ex.Message);
            }
            base.OnException(filterContext);
        }
    }
}